<?php
header("Content-type: text/html; charset=utf-8"); 
$DBconnect=@mysql_connect('localhost','root','')
  Or die('数据库无法连接');
@mysql_select_db('neu-video',$DBconnect)
  Or die('数据库不存在!');
//mysql_set_charset('utf-8');


$SQLstring ='select * from videos t1 left join videotype t2 on t1.tid=t2.tid';
$QueryResult = mysql_query($SQLstring,$DBconnect );

$arrs = fetch_array($QueryResult);//var_dump($users);
echo '<table border="1">';
echo '<caption>视频管理</caption>';
echo '<tr><th>序号</th><th>视频名称</th></th>视频类别</th><th>点击量</th></tr>';
foreach ($arrs as $index=>$one ) {
	echo '<tr>';
	echo '<td>'.($index+1).'</td>';
	echo '<td>'.$one['videoname'].'</td>';
	if($one['gender']==0){$sex='男';}
	else{$sex='女';}
	echo '<td>'.$sex.'</td>';
	echo '<td>'.$one['hobby'].'</td>';
	echo '</tr>';
}
echo '<table>';
function fetch_array($results){
	$arrs = array();
	while($results && ($row = mysql_fetch_assoc($results))!==FALSE){
		$arrs[]=$row;
}
return $arrs;
}

/*while($Result && ($row = mysql_fetch_assoc($results))!==FALSE){
echo $row['uname'].'<br>';

}*/
?>